<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>报价单管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <style>
        :root {
            --primary: #4361ee;
            --primary-light: #4895ef;
            --secondary: #3f37c9;
            --success: #4cc9f0;
            --danger: #f72585;
            --warning: #f8961e;
            --light: #f8f9fa;
            --dark: #212529;
            --gray: #6c757d;
            --light-gray: #e9ecef;
        }

        body {
            background: #f8fafc;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #334155;
        }

        .card {
            background: white;
            padding: 1.5rem;
            border-radius: 0.75rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
            margin-bottom: 1.5rem;
            transition: all 0.3s ease;
            border: 1px solid rgba(0, 0, 0, 0.04);
        }

        .card:hover {
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.5rem 1rem;
            border-radius: 0.5rem;
            font-weight: 500;
            transition: all 0.2s ease;
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            cursor: pointer;
            border: none;
            outline: none;
        }

        .btn:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
        }

        .btn-blue {
            background: var(--primary);
            color: white;
        }

        .btn-blue:hover {
            background: var(--secondary);
            transform: translateY(-1px);
        }

        .btn-gray {
            background: #f1f5f9;
            color: #64748b;
        }

        .btn-gray:hover {
            background: #e2e8f0;
            transform: translateY(-1px);
        }

        .form-input {
            padding: 0.6rem 1rem;
            border-radius: 0.5rem;
            border: 1px solid #d1d5db;
            transition: all 0.2s;
            width: 100%;
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        }

        .form-input:focus {
            outline: none;
            border-color: var(--primary-light);
            box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
        }

        .page-title {
            color: #1e293b;
            font-weight: 600;
            font-size: 1.5rem;
            margin-bottom: 1.5rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid #e2e8f0;
        }

        .section-title {
            color: #334155;
            font-weight: 600;
            font-size: 1.25rem;
            margin-bottom: 1rem;
        }

        .layui-table {
            border-radius: 0.5rem;
            overflow: hidden;
            box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
        }

        .layui-table thead tr {
            background: linear-gradient(to right, #f8fafc, #f1f5f9) !important;
        }

        .layui-table th {
            font-weight: 600;
            color: #334155;
        }

        .layui-table td, .layui-table th {
            padding: 0.75rem 1rem;
        }

        .layui-table tr:hover td {
            background-color: #f8fafc !important;
        }

        .layui-laypage a, .layui-laypage span {
            border-radius: 0.375rem !important;
            border: 1px solid #e2e8f0 !important;
        }

        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            background-color: var(--primary) !important;
            border-radius: 0.375rem !important;
        }

        .layui-table-header .layui-form-checkbox[lay-skin="primary"] {
            margin-top: 0;
        }

        .search-form {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
            align-items: end;
        }

        @media (min-width: 768px) {
            .search-form {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (min-width: 1024px) {
            .search-form {
                grid-template-columns: repeat(4, 1fr);
            }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .card {
            animation: fadeIn 0.5s ease-out;
        }

        .action-btn svg {
            margin-right: 4px;
            flex-shrink: 0;
        }

        .filter-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
            padding: 0.75rem;
            background: #f8fafc;
            border-radius: 0.5rem;
        }

        .column-filter {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
        }

        .column-filter-item {
            display: flex;
            align-items: center;
            padding: 0.25rem 0.5rem;
            background: white;
            border-radius: 0.375rem;
            border: 1px solid #e2e8f0;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .column-filter-item:hover {
            background: #edf2f7;
        }

        .column-filter-item.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }
    </style>
</head>
<body class="p-6 bg-gray-50">

<div class="max-w-7xl mx-auto">
    <!-- 页面标题 -->
    <h1 class="page-title">报价单管理</h1>

    <!-- 搜索栏 -->
    <div class="card">
        <h2 class="section-title">搜索筛选</h2>
        <form class="layui-form search-form" action="">
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">报价单名称</label>
                <input type="text" name="quotationName" placeholder="请输入报价单名称" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">报价单编号</label>
                <input type="text" name="quotationNo" placeholder="请输入报价单编号" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">订单编号</label>
                <input type="text" name="contractNo" placeholder="请输入订单编号" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">订单名称</label>
                <input type="text" name="contractName" placeholder="请输入订单名称" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">产品名称</label>
                <input type="text" name="itemName" placeholder="请输入产品名称" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">产品编号</label>
                <input type="text" name="itemNo" placeholder="请输入产品编号" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">客人名称</label>
                <input type="text" name="customerName" placeholder="请输入客人名称" class="form-input">
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">工厂名称</label>
                <input type="text" name="supplierName" placeholder="请输入工厂名称" class="form-input">
            </div>
            <div class="flex space-x-2 items-end">
                <button type="submit" class="btn btn-blue flex items-center" lay-submit lay-filter="data-search-btn">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                    </svg>
                    搜索
                </button>
                <button type="reset" class="btn btn-gray flex items-center" lay-submit lay-filter="data-refresh-btn">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
                    </svg>
                    刷新
                </button>
            </div>
        </form>
    </div>

    <!-- 表格区域 -->
    <div class="card">
        <div class="filter-container">
            <h2 class="section-title">报价单明细列表</h2>
        </div>

        <!-- Layui 表格 -->
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

<script src="/static/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="/static/js/common.js"></script>
<script>
    var lay, form, table;
    layui.use(['form', 'table', 'util'], function () {
        lay = layui.jquery;
        form = layui.form;
        table = layui.table;
        util = layui.util;

        // 列定义
        var columnDefinitions = {
            'id': {field: 'id', width: 65, title: 'ID', sort: true, group: 'basic'},
            'contractName': {field: 'contractName', width: 120, title: '订单名称', group: 'basic'},
            'contractNo': {field: 'contractNo', width: 120, title: '订单编号', group: 'basic'},
            'customerNo': {field: 'customerNo', width: 120, title: '客人编号', group: 'customer'},
            'customerName': {field: 'customerName', width: 120, title: '客人名称', group: 'customer'},
            'customerItemsNo': {field: 'customerItemsNo', width: 120, title: '客人货号', group: 'customer'},
            'customerPrice': {field: 'customerPrice', width: 80, title: '客人价格', group: 'customer'},
            'boxNumber': {field: 'boxNumber', width: 100, title: '数量', group: 'basic'},
            'innerBoxNumber': {field: 'innerBoxNumber', width: 100, title: '內盒数量', group: 'packaging'},
            'packaging': {field: 'packaging', width: 80, title: '包裝要求', group: 'packaging'},
            'upc': {field: 'upc', width: 100, title: 'UPC', group: 'product'},
            'moq': {field: 'moq', width: 120, title: 'MOQ', group: 'basic'},
            'itemName': {field: 'itemName', width: 120, title: '产品名称', group: 'product'},
            'itemNo': {field: 'itemNo', width: 120, title: '产品编号', group: 'product'},
            'supplierNo': {field: 'supplierNo', width: 120, title: '工厂编号', group: 'supplier'},
            'supplierName': {field: 'supplierName', width: 120, title: '工厂名称', group: 'supplier'},
            'supplierItemsNo': {field: 'supplierItemsNo', width: 120, title: '工厂货号', group: 'supplier'},
            'supplierPrice': {field: 'supplierPrice', width: 100, title: '工厂价格', group: 'supplier'},
            'itemSizeLength': {
                field: 'itemSizeLength',
                width: 120,
                title: '产品尺寸-长',
                group: 'product',
                templet: function (a) {
                    if (a.itemSizeLength) {
                        return $.utils.lengthConversion(a.itemSizeLength);
                    }
                    return '';
                }
            },
            'itemSizeWidth': {
                field: 'itemSizeWidth',
                width: 120,
                title: '产品尺寸-宽',
                group: 'product',
                templet: function (a) {
                    if (a.itemSizeWidth) {
                        return $.utils.lengthConversion(a.itemSizeWidth);
                    }
                    return '';
                }
            },
            'itemSizeHeight': {
                field: 'itemSizeHeight',
                width: 120,
                title: '产品尺寸-高',
                group: 'product',
                templet: function (a) {
                    if (a.itemSizeHeight) {
                        return $.utils.lengthConversion(a.itemSizeHeight);
                    }
                    return '';
                }
            },
            'innerBoxSizeLength': {field: 'innerBoxSizeLength', width: 120, title: '内箱-长cm', group: 'packaging'},
            'innerBoxSizeWidth': {field: 'innerBoxSizeWidth', width: 120, title: '内箱-宽cm', group: 'packaging'},
            'innerBoxSizeHeight': {field: 'innerBoxSizeHeight', width: 120, title: '内箱-高cm', group: 'packaging'},
            'boxSizeLength': {field: 'boxSizeLength', width: 120, title: '外箱-长cm', group: 'packaging'},
            'boxSizeWidth': {field: 'boxSizeWidth', width: 120, title: '外箱-宽', group: 'packaging'},
            'boxSizeHeight': {field: 'boxSizeHeight', width: 120, title: '外箱-高', group: 'packaging'},
            'boxSroughWeight': {field: 'boxSroughWeight', width: 100, title: '外箱-毛重', group: 'packaging'},
            'boxSuttle': {field: 'boxSuttle', width: 100, title: '外箱-净重', group: 'packaging'},
            'cubeNumber': {field: 'cubeNumber', width: 100, title: '立方数', group: 'packaging'},
            'justCount': {field: 'justCount', width: 100, title: '才数', group: 'packaging'},
            'itemQuality': {field: 'itemQuality', width: 100, title: '材质分析', group: 'product'},
            'itemUnit': {field: 'itemUnit', width: 100, title: '产品单位', group: 'product'},
            'itemWeight': {field: 'itemWeight', width: 100, title: '产品重量', group: 'product'},
            'remark': {field: 'remark', width: 200, title: '备注', group: 'basic'},
            'createTime': {
                field: 'createTime',
                width: 120,
                title: '创建时间',
                group: 'basic',
                templet: "<div>{{layui.util.toDateString(d.createTime, 'yyyy-MM-dd')}}</div>"
            },
            'updateUser': {field: 'updateUser', width: 100, title: '修改人', group: 'basic'},
            'updateTime': {
                field: 'updateTime',
                width: 120,
                title: '修改时间',
                group: 'basic',
                templet: "<div>{{layui.util.toDateString(d.updateTime, 'yyyy-MM-dd')}}</div>"
            }
        };

        // 获取所有列
        function getAllColumns() {
            return [
                {type: "checkbox", width: 50},
                columnDefinitions.id,
                columnDefinitions.contractName,
                columnDefinitions.contractNo,
                columnDefinitions.customerNo,
                columnDefinitions.customerName,
                columnDefinitions.customerItemsNo,
                columnDefinitions.customerPrice,
                columnDefinitions.boxNumber,
                columnDefinitions.innerBoxNumber,
                columnDefinitions.packaging,
                columnDefinitions.upc,
                columnDefinitions.moq,
                columnDefinitions.itemName,
                columnDefinitions.itemNo,
                columnDefinitions.supplierNo,
                columnDefinitions.supplierName,
                columnDefinitions.supplierItemsNo,
                columnDefinitions.supplierPrice,
                columnDefinitions.itemSizeLength,
                columnDefinitions.itemSizeWidth,
                columnDefinitions.itemSizeHeight,
                columnDefinitions.innerBoxSizeLength,
                columnDefinitions.innerBoxSizeWidth,
                columnDefinitions.innerBoxSizeHeight,
                columnDefinitions.boxSizeLength,
                columnDefinitions.boxSizeWidth,
                columnDefinitions.boxSizeHeight,
                columnDefinitions.boxSroughWeight,
                columnDefinitions.boxSuttle,
                columnDefinitions.cubeNumber,
                columnDefinitions.justCount,
                columnDefinitions.itemQuality,
                columnDefinitions.itemUnit,
                columnDefinitions.itemWeight,
                columnDefinitions.remark,
                columnDefinitions.createTime,
                columnDefinitions.updateUser,
                columnDefinitions.updateTime
            ];
        }

        // 初始化表格
        function initTable(columns) {
            table.render({
                elem: '#currentTableId',
                url: '/contractDetail/pages',
                toolbar: '#toolbarDemo',
                method: "post",
                request: {
                    pageName: "pageNum",
                    limitName: "pageSize"
                },
                contentType: "application/json; charset=utf-8",
                where: {
                    param: {}
                },
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [columns],
                done: function (res, curr, count) {
                    if ($.common.userIsAdmin()) {
                        $("[data-field='updateUser']").css('display', 'none');
                        $("[data-field='updateTime']").css('display', 'none');
                    }
                    if(!$.common.userIsShowPower()){
                        $("[data-field='customerPrice']").css('display', 'none');
                        $("[data-field='supplierPrice']").css('display', 'none');
                    }
                },
                limits: [5, 10, 15, 20, 25, 50, 100, 500],
                limit: 10,
                page: true,
                skin: 'line',
                even: true,
                text: {
                    none: '暂无相关数据'
                }
            });
        }

        // 初始渲染表格
        initTable(getAllColumns());

        // 搜索
        form.on('submit(data-search-btn)', function (data) {
            table.reload('currentTableId', {
                page: { curr: 1 },
                where: { param: data.field }
            });
            return false;
        });

        // 刷新
        form.on('submit(data-refresh-btn)', function () {
            table.reload('currentTableId', {
                where: { param: {} }
            });
            return false;
        });

    });
</script>

</body>
</html>